package org.broadway.exceptions;

import org.apache.commons.logging.Log;

/**
 * This is a general runtime exception used as the basis for other
 * Broadway exceptions.
 * @author vmatters
 *
 */
public abstract class ABroadException extends RuntimeException {
	/**
	 * Standard constructor
	 * @param msg exception's message.
	 */
	public ABroadException(String msg) {
		super(msg);
	}
	
	/**
	 * A constructor that will log exception message.
	 * @param msg - exception's message 
	 * @param log - logger to use to log message
	 */
	public ABroadException(String msg, Log log) {
		super(msg);
		log.error(msg);
	}
	
	/**
	 * A standard constructor
	 * @param ex exception
	 */
	public ABroadException(Throwable ex) {
		super(ex);
	}
	
	/**
	 * A constructor that will log the exception.
	 * @param ex thrown exception
	 * @param log logger used to log exception
	 */
	public ABroadException(Throwable ex, Log log) {
		super(ex);
		log.error(ex.getMessage(), ex);
	}
	
	/**
	 * A standard exception constructor
	 * @param msg - Textual exception message
	 * @param ex - Exception object
	 */
	public ABroadException(String msg, Throwable ex) {
		super(msg, ex);
	}
	
	/**
	 * A constructor that will log exception and exception message
	 * @param msg - exception message
	 * @param ex - actual excpetion object
	 * @param log - suitable logger to use.
	 */
	public ABroadException(String msg, Throwable ex, Log log) {
		super(msg, ex);
		log.error(msg, ex);
	}
}
